<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Form</title>
    <style type="text/css">
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      section {
        position: relative;
        min-height: 100vh;
        background: #fee648;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 20px;
      }
      .imgBx {
        width: 400px;
        height: 500px;
      }
      section .container {
        position: relative;
        width: 800px;
        height: 500px;
        background: #fff;
        box-shadow: 0 15px 50px rgba(0, 0, 0, 0.1);
        overflow: hidden;
      }
      section .container .user {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
      }
      section .container .user .imgBx {
        position: relative;
        width: 50%;
        height: 100%;
        background: #fff;
        transition: 0.5s;
      }
      section .container .user .imgBx img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      section .container .user .formBx {
        position: relative;
        width: 50%;
        height: 100%;
        background: #fff;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 40px;
        transition: 0.5s;
      }
      section .container .user .formBx h2 {
        font-size-adjust: 18px;
        font-weight: 600;
        text-transform: uppercase;
        text-align: center;
        width: 100%;
        letter-spacing: 2px;
        margin-bottom: 10px;
        color: #555;
      }
      section .container .user .formBx form input {
        position: relative;
        width: 100%;
        padding: 10px;
        background: #f5f5f5;
        color: #555;
        outline: none;
        box-shadow: none;
        border: none;
        margin: 8px 0;
        font-size: 14px;
        letter-spacing: 1px;
        font-weight: 300;
      }
      section .container .user .formBx form input[type='submit'] {
        max-width: 100px;
        background: #677eff;
        color: #fff;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        letter-spacing: 1px;
        transition: 0.5s;
      }
      section .container .user .formBx form .signup {
        position: relative;
        margin-top: 20px;
        font-size: 12px;
        letter-spacing: 1px;
        color: #555;
        text-transform: uppercase;
        font-weight: 300;
      }
      section .container .user .formBx form .signup a {
        font-weight: 600;
        color: #677eff;
        text-decoration: none;
      }
      section .container .signupBx {
        pointer-events: none;
      }
      section .container.active .signupBx {
        pointer-events: initial;
      }
      section .container .signupBx .formBx {
        left: 100%;
      }
      section .container.active .signupBx .formBx {
        left: 0;
      }
      section .container .signupBx .imgBx {
        left: -100%;
      }
      section .container.active .signupBx .imgBx {
        left: 0;
      }

      section .container .signinBx .formBx {
        left: 0;
      }
      section .container.active .signinBx .formBx {
        left: 100%;
      }
      section .container .signinBx .imgBx {
        left: 0;
      }
      section .container.active .signinBx .imgBx {
        left: 100%;
      }
    </style>
  </head>
  <body>
    <section>
      <div class="container">
        <!-- 登录 -->
        <div class="user signinBx">
          <div class="imgBx"><img src="img1.jpg" alt="" /></div>
          <div class="formBx">
            <form action="">
              <h2>Sign in</h2>
              <input type="text" name="username" placeholder="user" />
              <input type="password" name="password" placeholder="password" />
              <input type="submit" value="Login" />
              <p class="signup">
                Don't have an account? <a href="#" onclick="toggleForm()"> Sign Up</a>
              </p>
            </form>
          </div>
        </div>
        <div class="user signupBx">
          <div class="formBx">
            <!--注册-->
            <form action="">
              <h2>Create an Account</h2>
              <input type="text" name="username" placeholder="Username" />
              <input type="email" name="email" placeholder="Email Address" />
              <input type="password" name="password" placeholder="Password" />
              <input type="password" name="password" placeholder="Confirm Password" />
              <input type="submit" value="Sign Up" />
              <p class="signup">
                Already have an account? <a href="#" onclick="toggleForm()"> Sign In</a>
              </p>
            </form>
          </div>
          <div class="imgBx"><img src="img2.jpg" alt="" /></div>
        </div>
      </div>
    </section>
  </body>
  <script type="text/javascript">
    function toggleForm() {
      var container = document.querySelector('.container');
      container.classList.toggle('active');
    }
  </script>
</html>
